package lambda05;

import org.junit.Test;

import java.util.function.Consumer;

/**
 * Consumer接口
 *   一般用于只传递参数消费(执行)而不获取结果的操作
 *
 *   @FunctionalInterface
 * public interface Consumer<T> {
 *
 *    void accept(T t);
 *  }
 */
public class ComsumerDemo {
    @Test
    public void test01(){
        Consumer s = str-> System.out.println(str);
        s.accept("abcd"); // abcd
    }

    @Test
    public void test02(){
        method("def",str-> System.out.println(str.length())); // 3
    }

    public void method(String str,Consumer<String> c){
        c.accept(str);
    }
}
/*
* class ConsumerDemo02$$Lambda$1 implements Consumer<String>{
*
*       public void accept(String t){
*           sout.(t)
*       }
* }
* */